﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="Thksoft.Views.Apply.Index" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <%     var user = ViewBag.User as Sys_User;
           var company = new Sys_CompanyBLL().Find(user.USER_COMPANY);

           var CompanyName = company.CMY_NAME;
           var key = Guid.NewGuid();
           //查询部门所有人
           var userIdStr = new Sys_UserBLL().GetUserIdByCompanyId((int)company.CMY_ID); %>
    <div id="@key" style="margin: 0 auto; padding: 10px; width: 740px;">
        <div style="width: 100%; text-align: center; padding-top: 20px;">
            <input id="<%=key %>_CompanyId" type="hidden" value="@company.CMY_ID" />
            <input id="<%=key %>_BzId" type="hidden" value="@userIdStr" />
            <table border="0" cellpadding="0" cellspacing="0" width="100%" class="table">
                <tr>
                    <td colspan="4" style="text-align: center; font-weight: bold; font-size: medium;">
                        年度资金计划申请
                    </td>
                </tr>
                <tr>
                    <td class="lefttd">
                        部 门：
                    </td>
                    <td class="righttd">
                        <label><%=CompanyName %></label>
                    </td>
                    <td class="lefttd">
                        日 期：
                    </td>
                    <td class="righttd">
                        <input id="<%=key %>_ApplyDate" placeholder="请选择日期" value="<%=DateTime.Now.Year.ToString() %>"
                            class="Wdate INPUT DATE" type="text" onclick=" WdatePicker({dateFmt:'yyyy'})" />
                        <span style="color: Red;">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="lefttd">
                        编制依据及事由：
                    </td>
                    <td class="righttd" colspan="3">
                        <input id="<%=key %>_Title" placeholder="请输入编制依据及事由" value="" class="INPUT MAX" />
                        <span style="color: Red;">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="lefttd">
                        编制人：
                    </td>
                    <td class="righttd" colspan="3">
                        <input id="<%=key %>_BzStr" placeholder="请点选编制人" value="<%=CompanyName %>所有人" class="INPUT MAX" />
                        <span style="color: Red;">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="lefttd">
                        备 注：
                    </td>
                    <td colspan="3" class="righttd">
                        <textarea id="<%=key %>_Remark" class="INPUT" style="margin-top: 10px; width: 95%;
                            height: 60px;"></textarea>
                    </td>
                </tr>
                <tr>
                    <td style="text-align: center;" colspan="4">
                        <a id="<%=key %>_Lodding" style="color: blue;">加载默认项</a>
                        <button id="<%=key %>_Save" class="bt_css_s" type="button">
                            保存</button>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    </form>
</body>

<script type="text/javascript">
        $("#<%=key %>_Save").click(function () {
            var titileId = "<%=key %>_Title";
            var bzId = "<%=key %>_BzId";
            if ($("#" + titileId).val().trim() == "") {
                alert("编制依据及事由不能为空");
                return;
            }
            if ($("#" + bzId).val().trim() == "") {
                alert("请选择编制人");
                return;
            }
            if ($("#<%=key %>_ApplyDate").val().trim() == "") {
                alert("请选择资金申请年份");
                return;
            }
            var data = {};
            data.Type = "Year";
            data.Title = $("#" + titileId).val();
            data.BzId = $("#" + bzId).val();
            data.CompanyId = parseInt($("#<%=key %>_CompanyId").val());
            data.Year = $("#<%=key %>_ApplyDate").val();
            $.ajax({
                async: false,
                type:"POST",
                url: "/Apply/SubmitApplay",
                data: JSON.stringify(data),
                success: function (result) {
                    if (result.Type == 1) {
                        alert("申请成功");
                        return;
                    }
                    return alert(result.Msg);
                }
            });
         });
    </script>

</html>
